<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
         table {
            width: 100%;
            border: 1px solid #ccc;
            border-collapse: collapse;
            border-spacing: 0px;
          
        }

        table td {
            border: 1px solid #ccc;
            height: 30px;
            width: 100px;
        }
        .ibox{
            width: 100%;
            height: 100%;
            border: none;
            border-right: 1px solid #ccc;
        }
    </style>
</head>
<body>
    学号：<input type="text" id="v1" >
    姓名：<input type="text" id="v2" >
    性别：<input type="text" id="v3" >
    <button id="btn">添加</button>
    <table>
        <thead>
            <tr>
                <td>学号</td>
                <td>姓名</td>
                <td>性别</td>
                <td>操作</td>
            </tr>
           
        </thead>
        <tbody id="t">

        </tbody>
    </table>
   
    <script>
         btn.onclick=function(){
            var tr=document.createElement("tr")
            
            t.appendChild(tr)
            
            var td1=document.createElement("td")
          
            td1.innerHTML= '<input class="ibox" type="text" value='+v1.value+' >'
            tr.appendChild(td1)
            var td2=document.createElement("td")
            td2.innerHTML='<input class="ibox" type="text" value='+v2.value+' >'
            tr.appendChild(td2)
            var td3=document.createElement("td")
            td3.innerHTML='<input class="ibox" type="text" value='+v3.value+' >'
            tr.appendChild(td3)
            var td4=document.createElement("td")
            td4.innerHTML="<button class='box'>删除</button>"
            tr.appendChild(td4)
            v1.value=""
            v2.value=""
            v3.value=""
            

            var box=document.getElementsByClassName("box")
            for(let i=0;i<box.length;i++){
                box[i].onclick=function(){
                    this.parentElement.parentElement.remove()
                }
            }
           
        }
    </script>
</body>
</html>